import { expect } from 'chai';
import calculateAge from '../src/calculateAge';

describe('calculateAge unit test', function () {
    it('should return -1 if arguments is missing', function () {
        expect(calculateAge()).to.equal(-1);
    });

    it('should return 18 for valid date', function () {
        expect(calculateAge([2000, 1, 1], [2018, 1, 1])).to.equal(18);
    });

    it('should return 17 for valid date', function () {
        expect(calculateAge([2000, 1, 2], [2018, 1, 1])).to.equal(17);
    });

    it('should return 17 for valid date with less month', function () {
        expect(calculateAge([2000, 2, 1], [2018, 1, 1])).to.equal(17);
    });

    it('should return 17 for valid date', function () {
        expect(calculateAge([2000, 2, 29], [2018, 2, 28])).to.equal(17);
    });

    it('should return -1 for invalid arguments', function () {
        expect(calculateAge(1, 2)).to.equal(-1);
    });

    it('should return -1 for invalid arguments', function () {
        expect(calculateAge([1, 2, 'a'], [1, 2, 3])).to.equal(-1);
    });

    it('should return -1 for invalid arguments', function () {
        expect(calculateAge([1, 2], [1, 2])).to.equal(-1);
    });
});
